home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 July / macformat52.iso / mac / Shareware Plus / Developers / YAAF v1.0 alpha 1 / (Sources) / Standard Controls / Images / XGStdPicture.cpp < prev   
Encoding:
C/C++ Source or Header  |  1997-04-24  |  2.6 KB  |  109 lines

  1. /*    XGStdPicture.cpp
  2.  *
  3.  *        This is a standard control for displaying a static picture
  4.  */
  5.  
  6. /*  YAAF - Yet another application framework
  7.  *  Copyright (C) 1997 William Edward Woody and In Phase Consulting
  8.  *  
  9.  *  This library is free software; you can redistribute it
  10.  *  and/or modify it under the terms of the GNU Library
  11.  *  General Public License as published by the Free Software
  12.  *  Foundation; either version 2 of the License, or any
  13.  *  later version.
  14.  *  
  15.  *  This library is distributed in the hope that it will be
  16.  *  useful, but WITHOUT ANY WARRANTY; without even the implied
  17.  *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
  18.  *  PURPOSE. See the GNU Library General Public License for
  19.  *  more details.
  20.  *  
  21.  *  You should have received a copy of the GNU Library General
  22.  *  Public License along with this library; if not, write to the
  23.  *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24.  *  Boston, MA 02111-1307, USA.
  25.  *  
  26.  *  To contact the author, either e-mail me at
  27.  *  woody@alumni.caltech.edu, or write to us at
  28.  *  
  29.  *          William Edward Woody
  30.  *          In Phase Consulting
  31.  *          1545 Ard Eevin Avenue
  32.  *          Glendale, CA 91202
  33.  */
  34.  
  35. #include <XStdImage.h>
  36.  
  37. /************************************************************************/
  38. /*                                                                        */
  39. /*    Construction/Destruction                                            */
  40. /*                                                                        */
  41. /************************************************************************/
  42.  
  43. /*    XGStdPicture::XGStdPicture
  44.  *
  45.  *        Standard picture initialization
  46.  */
  47.  
  48. XGStdPicture::XGStdPicture(XGView *p, XGArgStream &i) : XGView(p,i)
  49. {
  50.     Init(i.GetInteger());
  51. }
  52.  
  53. XGStdPicture::XGStdPicture(XGView *p, XGSImageInitRecord &i) : XGView(p,i.v)
  54. {
  55.     Init(i.image);
  56. }
  57.  
  58. /*    XGStdPicture::~XGStdPicture
  59.  *
  60.  *        Fry this
  61.  */
  62.  
  63. XGStdPicture::~XGStdPicture()
  64. {
  65. #if OPT_MACOS == 1
  66.     if (fPicture) ReleaseResource((Handle)fPicture);
  67. #endif
  68. }
  69.  
  70. /************************************************************************/
  71. /*                                                                        */
  72. /*    Image Drawing                                                        */
  73. /*                                                                        */
  74. /************************************************************************/
  75.  
  76. /*    XGStdPicture::DoDrawView
  77.  *
  78.  *        Draw the picture
  79.  */
  80.  
  81. void XGStdPicture::DoDrawView(Rect)
  82. {
  83. #if OPT_MACOS == 1
  84.     Rect r;
  85.     XGDraw draw(this);
  86.     
  87.     r = GetContentRect();
  88.     ::DrawPicture(fPicture,&r);
  89. #endif
  90. }
  91.  
  92. /************************************************************************/
  93. /*                                                                        */
  94. /*    Initialization                                                        */
  95. /*                                                                        */
  96. /************************************************************************/
  97.  
  98. /*    XGStdPicture::Init
  99.  *
  100.  *        Initialize me
  101.  */
  102.  
  103. void XGStdPicture::Init(short resID)
  104. {
  105. #if OPT_MACOS == 1
  106.     fPicture = GetPicture(resID);
  107. #endif
  108. }
  109.